//用户优惠券
exports.user_coupon = function (req, res) {

    //获取restful参数
    var restfulParams = req.routeInfo.restfulParams;

    //最终结果
    var resultData = {};

    //任务流创建
    async.waterfall([
            //1.代金券
            function (cb) {
                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.userCashCoupon + "/ucc_uid/" + restfulParams.ucc_uid,
                        method: 'POST',
                        data: {
                            fields: ["ucc_id", "ucc_is_used", "cc_name", "cc_price", "cc_start_time", "cc_end_time", "o_name"].join(",")
                        }
                    },
                    function (err, data) {
                        //判断是否有错误信息
                        if (err) {
                            return cb(err, data);
                        }

                        resultData.cashCouponData = data.data;
                        cb();
                    }
                );

            },
            //2.约课券
            function (cb) {
                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.userCourseCoupon + "/ucc_uid/" + restfulParams.ucc_uid,
                        method: 'POST',
                        data: {
                            fields: ["ucc_id", "ucc_is_used", "cc_name", "cc_start_time", "cc_end_time", "o_name"].join(",")
                        }
                    },
                    function (err, data) {
                        //判断是否有错误信息
                        if (err) {
                            return cb(err, data);
                        }

                        resultData.courseCouponData = data.data;
                        cb();
                    }
                );
            },
            //3.兑换券
            function (cb) {
                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.userExchangeCoupon + "/uec_uid/" + restfulParams.ucc_uid,
                        method: 'POST',
                        data: {
                            fields: ["uec_id", "uec_is_used", "ec_name", "ec_start_time", "ec_end_time", "o_name", "uec_exchange_code"].join(",")
                        }
                    },
                    function (err, data) {
                        //判断是否有错误信息
                        if (err) {
                            return cb(err, data);
                        }

                        resultData.exchangeCouponData = data.data;
                        cb();
                    }
                );
            }
        ], function (err, result) {

            //返回最终拼接结果
            RES.response(res, true, resultData);

        }
    );

}